require('../../assets/css/index.js');//引入的是公共css和复用css
const dom = require('../../utils/dom.js');  //引入节点操作js
require('../../lib/swiper/swiper-3.4.2.min (1).css')//轮播图
let Swiper = require('../../lib/swiper/swiper-3.4.2.min.js')//轮播图
const https = require('../../utils/https.js'); //请求封装
require('../../assets/css/public.less')//公共样式底部
require('./home.less');//自己

new Swiper('.swiper', {
    effect:'flip',
    loop: true, // 循环模式选项
    autoplay: 2000,
    // 如果需要分页器
    pagination: {
        el: '.swiper-pagination',
    },
})
//获取打卡参数和状态
https.get('/api/user/clockInInfo',{},res=>{
    let { errno, data } = res; //res得到的值分配
    if (errno == 0){
         dom.getE('.ranking-right').innerHTML= ` <h3>&nbsp;累计打卡${data.clockCount}天</h3>
           <button>${data.isClockIn ? '已经打卡' : '点我打卡'}</button>`
    }
})

dom.getE('.ranking-right').addEventListener('click',()=>{
    https.post('/api/user/clockIn',{},res=>{
    let { errno, data } = res; //res得到的值分配
    if (errno == 0){
        alert("打卡成功");
        history.go(0)
    }else if(errno == -1){
        alert('打过卡就不要打了')
    }
    })
})




